READ and WRITE composite variables
Components of composite variables can be read or written with READ and WRITE.
Components can be simple variables, fixed-size strings, fixed-size arrays, or array
elements. The follow code segment illustrates these combinations:
'
' ***** PROLOG *****
'
TYPE POINT ' User defined type POINT
XLONG .x ' component .x
XLONG .y ' component .y
XLONG .z ' component .z
END TYPE
'
TYPE LINE
POINT .a
' POINT in the line
POINT .b
'
POINT in the line
USHORT .color[2] ' three color values (r, g, b)
END TYPE
'
TYPE BOX
LINE .top
' top line in box
LINE .left
' left line in box
LINE .right
'
right line in box
LINE .bottom '
bottom line in box
STRING*20 .name ' name of this box
END TYPE
'
DECLARE FUNCTION ReadWrite (o, i) '
... '
FUNCTION ReadWriteDemo (o, i) '
SHARED BOX box0, box1 '
SHARED LINE a, b, c, d '
SHARED POINT a0, a1, b0, b1 '
' '
WRITE [o], box0 ' write entire BOX variable
WRITE [o], box1.top ' write .top LINE component
WRITE [o], box1.name ' write .name STRING * 20
WRITE [o], box0.top.color[] ' write .color array
WRITE [o], box1.left.color[n] ' write .color array element
'
READ [i], box1 ' read entire BOX variable
READ [i], box0.left ' read .left LINE component
READ [i], box0.name ' read .name STRING * 20
READ [i], box0.right.color[] ' read .color array
READ [i], box0.bottom.color[1] ' read .color array element
END FUNCTION